/*
 * @Author: shengduiliang 1107722390@qq.com
 * @Date: 2024-05-04 16:49:56
 * @LastEditors: shengduiliang 1107722390@qq.com
 * @LastEditTime: 2024-05-05 16:58:57
 * @FilePath: /treasure/src/ui-components/text-input/index.tsx
 * @Description: 输入框组件
 */
import { View } from "@tarojs/components"
import { memo } from "react"
import classNames from "classnames"
import './index.scss'

interface TextInputProps {
  label: string
  value?: string | number
  left?: boolean  // 右边文本对齐方式
  renderRight?: () => JSX.Element
}

const TextArea = (props: TextInputProps) => {
  return (
    <View className='text-item pv-normal-mh-normal'>
      <View className='row-start-center'>
        <View className='label text-primary-bold'>{props.label}</View>
        <View className={classNames('text-primary flex-1', props.left ? 'text-left' : 'text-right')}>
          {
            props.renderRight ? props.renderRight() : <View className='text-primary'>
              { props.value }
            </View>
          }
        </View>
      </View>
    </View>
  )
}

export default memo(TextArea)